#ifndef MAIN_HH_
# define MAIN_HH_

# include <boost/thread.hpp>

// possess an indirect include to map so must be first
# include "display/displayer.hh"

#include "content-handler.hh"

# include "action/action_queue.hh"
# include "action/obj_action.hh"

# include "server.hh"
# include "gui/window.hh"
# include "gui/text-img.hh"

# include "keyboard/keyboard.hh"
# include "gui/chat.hh"
# include "gui/menu/menu-handler.hh"

# include "raycaster/ray.hh"
# include <tools/utility.hh>
# include "action/delta.hh"

# include <iostream>
# include <sstream>

class Main
{
public:
  Main (int argc, char** argv, Server* serv);
  ~Main ();

  void loop ();

  // Rts actions
  void treat_action (ActionRtsMove* act);
  void treat_action (ActionRtsExit* act);
  void treat_action (ActionRtsMoveObj* act);
  void treat_action (ActionRtsRotateObj* act);

  // Fps actions
  void treat_action (ActionFpsMove* act);
  void treat_action (ActionFpsExit* act);

  // Chat actions
  void treat_action (ActionChat* act);
  void treat_action (ActionChatES* act);
  void treat_action (ActionChatDel* act);
  void treat_action (ActionChatAdd* act);

  // Common actions
  void treat_action (ActionSendText* act);
  void treat_action (ActionNewMessage* act);
  void treat_action (ActionChatCurMove* act);
  void treat_action (ActionResetSelection* act);

protected:
  void build_menu ();
  void findid (unsigned char* p);

  Window* w;
  Camera* c;
  Keyboard* k;
  Server* s;
  boost::thread listen;
  Mouse* m;

  MenuHandler* mh;
  Chat* chat;

  bool go;

  Displayer* d;
  std::list<Blitable*> interface;
  TextImg* fps;

  std::queue<Action*>* queue_;

  // player infos
  std::string player_name;

  // input sending to server
  std::map<int, ObjAction*>* obj_act_;
};

#endif /// !MAIN_HH_
